package com.multimedia.scala.euler

import scala.collection.mutable.ListBuffer
/*
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10001st prime number?
 */
object Asd7 {
  def main(args : Array[String]) : Unit = {
      val num = 10001
	  def isSimpleNum(x: BigInt, simples: ListBuffer[BigInt]): Boolean = {
	      if (simples.length==num) println(simples.last)
          for (j <- simples) {
              if (x%j==0) return false
          }
          simples += x
    	  true
	  }
	  
	  var simples = ListBuffer[BigInt]()
	  (2 to 1000000).foreach(isSimpleNum(_:Int, simples))
  }
}
